﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;


namespace BFOAuction
{
    public partial class Login1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string cn = DataProvider.DataProvider.Connection();
            SqlConnection con = new SqlConnection(cn);
            con.Open();
            string strSql = "Select count(*) from Account where Username ='" + txtUsername.Text + "'";
            SqlCommand UserExist = new SqlCommand(strSql, con);
            int temp = Convert.ToInt32(UserExist.ExecuteScalar().ToString());

            if (temp == 1)
            {
                string sql2 = "Select Passw from Account where Username ='" + txtUsername.Text + "'";
                SqlCommand pass = new SqlCommand(sql2, con);
                string Passw = pass.ExecuteScalar().ToString();

                if (Passw == txtPass.Text)
                {
                    Session["new"] = txtUsername.Text;
                    Response.Redirect("Default.aspx");
                }
                else
                {
                    Label1.Visible = true;
                    Label1.Text = "Invalid pass...!!!";
                }
            }
            else
            {
                Label1.Visible = true;
                Label1.Text = "Invalid username...!!!";
            }
            con.Close();
        }
    }
}